Preventing code under location variable from running until it is assigned